package com.skywolf.chem.common.sysconfig;

/**
 * Created by pei_pei on 2020/10/27.
 */
import java.time.Duration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestAutoConfig {
    public RestAutoConfig() {
    }

    @ConditionalOnMissingBean
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        RestTemplate restTemplate = builder.setConnectTimeout(Duration.ofSeconds(10L)).setReadTimeout(Duration.ofSeconds(10L)).build();
        return restTemplate;
    }
}